//
//  PHAsset+x.h
//  XPhoto
//
//  Created by baboy on 2019/2/22.
//  Copyright © 2019 baboy. All rights reserved.
//

#import <Photos/Photos.h>

NS_ASSUME_NONNULL_BEGIN

@interface PHAsset(x)
+ (PHFetchResult<PHAsset *> *)fetchAllAssetsWithMediaType:(PHAssetMediaType)mediaType soryByCreationDateAsc:(BOOL)isAsc;
-(CGSize)imageSize;


-(void)loadHighQualityImageWithProgressHandler:(void(^)(double progress, NSError * error))progressHandler resultHandler:(void (^)(UIImage* result, NSDictionary * info))resultHandler;

-(void)loadHighQualityImageSynchronousWithProgressHandler:(void(^)(double progress, NSError * error))progressHandler resultHandler:(void (^)(UIImage* result, NSDictionary * info))resultHandler;

-(void)loadLowQualityImageWithTargetSize:(CGSize)targetSize progressHandler:(void(^)(double progress, NSError * error))progressHandler resultHandler:(void (^)(UIImage* result, NSDictionary * info))resultHandler;

- (void)videoURLAssetWithProgressHandler:(void(^)(double progress, NSError * error))progressHandler
                           resultHandler:(void(^)(AVURLAsset *urlAsset, NSError *error)) resultHandler;

- (void)requestImageWithResultHandler:(void(^)(UIImage *image)) resultHandler;
- (void)exportToFilePath:(NSString *)fp  resultHandler:(void(^)(NSError *error)) resultHandler;
+ (void)saveImageToPhotoLib:(UIImage *)image resultHandler:(void(^)(PHAsset *asset, NSError *error)) resultHandler;
+ (void)saveVideoToPhotoLib:(NSURL *)videoURL resultHandler:(void(^)(PHAsset *asset, NSError *error)) resultHandler;

@end

NS_ASSUME_NONNULL_END
